<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('房屋标签列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>标签名称：</label>
                                <input type="text" name="name"/>
                            </li>
                            <li>
                                <label>优先级：</label>
                                <select class="form-control m-b" name="prior" id="selectType">
                                    <option value="">所有</option>
                                    <option value="1">高级</option>
                                    <option value="2">中等</option>
                                    <option value="3">普通</option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="admin:tag:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="admin:tag:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="admin:tag:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="admin:tag:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('admin:tag:edit')}]];
        var removeFlag = [[${@permission.hasPermi('admin:tag:remove')}]];
        var prefix = ctx + "admin/tag";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "房屋标签",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'tagId',
                    title: '标签唯一标识',
                    visible: false
                },
                {
                    field: 'name',
                    title: '标签名称',
                    formatter: function (value, row, index) {
                        return '<i class="fa fa-tag"></i> '+row.name
                    }
                },
                {
                    field: 'prior',
                    title: '显示优先级',
                    align: 'center',
                    formatter: function (value, row, index) {
                        if (row.prior == 1) {
                            return '<strong>高级</strong>';
                        } else if (row.prior == 2){
                            return '<strong>中等</strong>';
                        } else if (row.prior == 3){
                            return '<strong>普通</strong>';
                        }
                    },
                    cellStyle: function(value,row,index){
                        if (row.prior == 1) {
                            return {
                                css:{
                                    'color':'#510080'
                                }
                            };
                        } else if (row.prior == 2){
                            return {
                                css:{
                                    'color':'#ec9f12'
                                }
                            };
                        } else if (row.prior == 3){
                            return {
                                css:{
                                    'color':'#008018'
                                }
                            };
                        }
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.tagId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.tagId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>